<template>
	<view class="block-notices" v-if="data.length>0">
		<text class="iconfont icon-notice"></text>
		<swiper class="notices" :style="{height:noticeHeight+'px',lineHeight: noticeHeight+'px'}" 
		:vertical="vertical" :autoplay="autoplay" :circular="circular" :interval="interval" :duration="duration">
			<swiper-item v-for="(item,index) in data" :key="index" @click="goPage(item.href,item.id,item.status)">
				<view class="swiper-item">{{item.title}}</view>
			</swiper-item>
		</swiper>
	</view>
</template>

<script>
	export default {
		name:"BlockNotice",
		props:{
			data:{
				default:[Array],
				default(){
					return []
				}
			},
			vertical:{
				type:[Boolean],
				default:true
			},
			autoplay:{
				type:[Boolean],
				default:true
			},
			circular:{
				type:[Boolean],
				default:true
			},
			interval:{
				type:[Number],
				default:3000
			},
			duration:{
				type:[Number],
				default:500
			},
			noticeHeight:{
				type:[Number],
				default:25
			}
		},
		methods:{
			goPage(url,id,status){
				if(status){
					if(url){
						uni.navigateTo({
							url:"/pages/link/link?url="+url
						})
					}else{
						uni.navigateTo({
							url:'/pages/public/notice-detail/notice-detail?id='+id
						})
					}
				}else{
					uni.navigateTo({
						url:url
					})
				}
				
			},
		}
	}
</script>

<style lang="less" scoped src="./BlockNotice.less"></style>
